<?php
/**
 * IndexController.class.php
 * 首页控制器
 *
 * @author 	王中艺
 * @date 	2016-10-21
 */

namespace Home\Controller;
use Think\Controller;

class IndexController extends Controller {
	function redisList(){
		$redis 	= \Common\Util\Redis::getInstance();
		$messages 	= array(
			array('from' => 'wangzy', 'to' => 'xinletu', 'content' => 'message content 1', 'time' => time()),
			array('from' => 'xinletu', 'to' => 'wangzy', 'content' => 'message content 2', 'time' => time()),
			array('from' => 'wangzy', 'to' => 'haiwai', 'content' => 'message content 3', 'time' => time()),
			array('from' => 'haiwai', 'to' => 'wangzy', 'content' => 'message content 4', 'time' => time()),
		);
		foreach($messages as $item){
			$redis->rpush('message_list', json_encode($item));
		}
		while(true){
			$message 	= $redis->lpop('message_list');
			if(!$message) break;
			dump(json_encode($message));
		}
		dump($redis->lrange('message_list', 0, -1));
	}

	function serverInfo(){
		echo '<pre>';
		dump(__ROOT__);
		var_dump($_SERVER);
	}
}